class Solution:
    def firstUniqChar(self, s: str) -> str:
        d = dict()
        z = set()
        for i, c in enumerate(s):
            if c not in z:
                if c in d:
                    d.pop(c)
                    z.add(c)
                else:
                    d[c]=i
        m, n = len(s), ' '
        for k,v in d.items():
            if v <= m:
                m, n = v, k
        return n

if __name__ == '__main__':
    c = Solution()
    print(c.firstUniqChar(""))